<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/views/include/taglib.jsp" %>

<!DOCTYPE html> <!--[if IE 8]> <html lang="zh" class="ie8 no-js"> <![endif]--> <!--[if IE 9]> <html lang="zh" class="ie9 no-js"> <![endif]--> <!--[if !IE]><!-->
<html lang="zh">
<!--<![endif]-->

<!-- BEGIN HEAD -->
<head>
    <title>${fns:getConfig('productName')} | 流程管理</title>
    <meta name="decorator" content="default"/>
</head>
<!-- END HEAD -->
<body class="page-container-bg-solid page-header-fixed page-sidebar-closed-hide-logo">
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <!-- BEGIN SIDEBAR -->
    <div class="page-sidebar-wrapper">
        <!-- BEGIN SIDEBAR -->
        <div class="page-sidebar navbar-collapse collapse">
            <!-- BEGIN SIDEBAR MENU -->
            <ul class="page-sidebar-menu" data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">
                <li class="heading">
                    <h3 class="uppercase">流程管理</h3>
                </li>
                <t:menu menu="${fns:getTopMenu()}" parentName="在线办公" currentName="流程管理"></t:menu>
            </ul>
            <!-- END SIDEBAR MENU -->
        </div>
        <!-- END SIDEBAR -->
    </div>
    <!-- BEGIN CONTENT -->
    <div class="page-content-wrapper">
        <!-- BEGIN CONTENT BODY -->
        <div class="page-content" style="padding-top: 0;">
            <!-- BEGIN PAGE HEADER-->

            <!-- BEGIN TABLE -->
            <div class="row">
                <div class="col-md-12">

                    <div class="portlet light">
                        <div class="portlet-title">
                            <div class="caption">
                                <span class="caption-subject bold font-grey-gallery uppercase"> 流程管理 </span>
                                <span class="caption-helper"></span>
                            </div>
                            <div class="tools">
                                <a href="" class="fullscreen"> </a>
                            </div>
                        </div>


                        <!--查询条件-->
                        <div class="row">
                            <div class="col-sm-12">
                                <form:form id="searchForm" modelAttribute="category" action="${ctx}/act/process/" method="post" class="form-inline">
                                    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                                    <table:sortColumn id="orderBy" name="orderBy" value="${page.orderBy}" callback="sortOrRefresh();"/><!-- 支持排序 -->
                                    <div class="form-group">
                                        <select id="category" name="category" class="form-control">
                                            <option value="">全部分类</option>
                                            <c:forEach items="${fns:getDictList('act_category')}" var="dict">
                                                <option value="${dict.value}" ${dict.value==category?'selected':''}>${dict.label}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                </form:form>
                                <br/>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="pull-left">
                                    <table:addRow url="${ctx}/act/process/deploy/"  label="上传流程文件" title="流程"></table:addRow><!-- 增加按钮 -->
                                    <button class="btn btn-default btn-sm" onclick="sortOrRefresh()"><i class="fa fa-repeat"></i> 刷新</button>

                                </div>
                                <div class="pull-right">
                                    <button  class="btn btn-primary btn-sm" onclick="search()" ><i class="fa fa-search"></i> 查询</button>
                                    <button  class="btn btn-info btn-sm" onclick="reset()" ><i class="fa fa-refresh"></i> 重置</button>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-12">
                                <div class="table-scrollable">
                                    <table id="contentTable" class="table table-striped table-bordered table-hover">
                                        <thead>
                                        <tr style="white-space: nowrap;">
                                            <th>流程分类</th>
                                            <th>流程ID</th>
                                            <th>流程标识</th>
                                            <th>流程名称</th>
                                            <th>流程版本</th>
                                            <th>流程XML</th>
                                            <th>流程图</th>
                                            <th>部署时间</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <c:forEach items="${page.list}" var="object">
                                            <c:set var="process" value="${object[0]}"/>
                                            <c:set var="deployment" value="${object[1]}"/>
                                            <tr class="active">
                                                <td>
                                                    <a href="javascript:updateCategory('${process.id}', '${process.category}')"
                                                       title="设置分类">${fns:getDictLabel(process.category,'act_category','无分类')}</a>
                                                </td>
                                                <td>${process.id}</td>
                                                <td>${process.key}</td>
                                                <td>${process.name}</td>
                                                <td><b title='流程版本号'>V: ${process.version}</b></td>
                                                <td><a target="_blank"
                                                       href="${ctx}/act/process/resource/read?procDefId=${process.id}&resType=xml">${process.resourceName}</a>
                                                </td>
                                                <td><a target="_blank"
                                                       href="${ctx}/act/process/resource/read?procDefId=${process.id}&resType=image">${process.diagramResourceName}</a>
                                                </td>
                                                <td><fmt:formatDate value="${deployment.deploymentTime}"
                                                                    pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                                <td>
                                                    <c:if test="${process.suspended}">
                                                        <a href="${ctx}/act/process/update/active?procDefId=${process.id}"
                                                           onclick="return Custom.initBootBoxConfirm('确认要激活吗？', this.href)"
                                                           class="btn btn-info btn-xs"><i
                                                                class="fa fa-search-plus"></i>激活</a>
                                                    </c:if>
                                                    <c:if test="${!process.suspended}">
                                                        <a href="${ctx}/act/process/update/suspend?procDefId=${process.id}"
                                                           onclick="return Custom.initBootBoxConfirm('确认挂起除吗？', this.href)"
                                                           class="btn btn-success btn-xs"><i class="fa fa-edit"></i>
                                                            挂起</a>
                                                    </c:if>
                                                    <a href='${ctx}/act/process/delete?deploymentId=${process.deploymentId}'
                                                       onclick="return Custom.initBootBoxConfirm('确认要删除该流程吗？', this.href)"
                                                       class="btn btn-danger btn-xs"><i class="fa fa-trash"></i> 删除</a>
                                                    <a href='${ctx}/act/process/convert/toModel?procDefId=${process.id}'
                                                       onclick="return Custom.initBootBoxConfirm('确认要转换为模型吗？', this.href)"
                                                       class="btn btn-info btn-xs"><i class="fa fa-"></i>转换为模型</a>
                                                </td>
                                            </tr>
                                        </c:forEach>
                                        </tbody>
                                    </table>
                                </div>
                                <div>${page}</div>
                            </div>
                        </div>

                    </div>


                </div>
            </div>
            <!-- END TABLE -->
        </div>
        <!-- END CONTENT BODY -->
    </div>
    <!-- END CONTENT -->
</div>
<!-- END CONTAINER -->

<!-- BEGIN MODAL -->
<div class="modal fade modal-scroll in" id="categoryModal" role="basic" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <form id="categoryForm" action="${ctx}/act/process/updateCategory" method="post" class="form-horizontal"
                  onsubmit="Custom.initStartPageBlockUI();">
                <input id="categoryBoxId" type="hidden" name="procDefId" value=""/>
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title">设置分类</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group form-md-line-input">
                        <div style="padding-left:20px; padding-right: 20px;">
                            <select id="categoryBoxCategory" name="category" class="form-control">
                                <c:forEach items="${fns:getDictList('act_category')}" var="dict">
                                    <option value="${dict.value}">${dict.label}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <input id="categorySubmit" class="btn blue" type="submit" value="  保  存  "/>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- END MODAL -->

<%@include file="/views/include/foot.jsp" %>

<script type="text/javascript">
    function add(){
        openDialog("新增"+'流程',"${ctx}/act/process/deploy/","800px", "500px","");
    }

    function page(n, s) {
        Custom.initStartPageBlockUI();
        location = '${ctx}/act/process/?pageNo=' + n + '&pageSize=' + s;
    }

    function updateCategory(id, category) {
        $("#categoryBoxId").val(id);
        $("#categoryBoxCategory").val(category);
        $("#categoryModal").modal("show");
    }
</script>
</body>
</html>